﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Forum.DataAccess.DbModel;

namespace Forum.Domain.Managers
{
    public class PostManager : ManagerBase
    {
        public PostManager(){}

        public Post GetPost(int id)
        {

            return (from p in DbContext.Posts
                    where p.Id == id
                    select p).SingleOrDefault();
        }

        public List<Post> GetAllPosts()
        {
            return (from p in DbContext.Posts
                    select p).ToList();
        }

        public void CreatePost(Post post)
        {
            DbContext.Posts.AddObject(post);
            DbContext.SaveChanges();
        }
    }
}
